import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import { CustomerQueryForm } from '@/modules/CustomerTable';

/**
 * @name 表格筛选表单
 * @param { Function } onSearch 搜索事件
 */
const TableQueryForm = ({ onSearch }) => {
  const data = useMemo(
    () => [
      {
        type: 'select',
        name: 'sourceApplicationNum',
        label: '来源应用',
        valueEnum: {
          CMOS: 'CMOS',
          CMOS2: 'CMOS2',
          MOM2: 'MOM2',
        },
      },
      {
        type: 'input',
        name: 'sourceApplicationName',
        label: '应用名称',
      },
      {
        type: 'input',
        name: 'processName',
        label: '流程模板名称',
      },
      {
        type: 'input',
        name: 'nodeCode',
        label: '任务编码',
      },
      {
        type: 'input',
        name: 'modelKey',
        label: '业务类型编码',
      },
      {
        type: 'input',
        name: 'businessCode',
        label: '业务编号',
      },
      {
        type: 'select',
        name: 'status',
        label: '状态',
        valueEnum: {
          TODO: '待办',
          DONE: '已办',
          RECALL: '已撤回',
        },
      },
      {
        type: 'input',
        name: 'taskInstanceId',
        label: '任务实例ID',
      },
      {
        type: 'input',
        name: 'processInstanceId',
        label: '流程实例ID',
      },
      {
        type: 'input',
        name: 'createNameOrCode',
        label: '创建人',
        placeholder: '请输入工号或姓名',
      },
      {
        type: 'dateRange',
        key: 'dateStart',
        name: [
          ['createTime', 'startTime'],
          ['createTime', 'endTime'],
        ],
        label: '创建时间',
      },
      {
        type: 'dateRange',
        key: 'expireTime',
        name: [
          ['expireTime', 'startTime'],
          ['expireTime', 'endTime'],
        ],
        label: '计划完成时间',
      },
      {
        type: 'select',
        name: 'taskType',
        label: '待办任务类型',
        valueEnum: {
          Editing: '编制中',
          Auditing: '审批中',
        },
      },
      {
        type: 'input',
        name: 'fieldAreaKey',
        label: '业务字段编码',
      },
      {
        type: 'input',
        name: 'fieldAreaValue',
        label: '业务字段值',
      },
    ],
    [],
  );
  return (
    <div style={{ background: '#fff', marginBottom: 10, padding: 10 }}>
      <CustomerQueryForm data={data} onFinish={onSearch} />
    </div>
  );
};

TableQueryForm.propTypes = {
  onSearch: PropTypes.func,
};

TableQueryForm.defaultProps = {
  onSearch: () => {},
};

export default TableQueryForm;
